<template>
  <div>
    <div class="user-area">
      <div class="title">
        <div class="point"></div>
        <span>公告</span>
      </div>
      <el-form>
        <el-form-item label="公告">
          <el-col :span="15">
            <el-input type="textarea"
                      maxlength="45"
                      v-model="notice"></el-input>
          </el-col>
        </el-form-item>
        <el-form-item>
          <el-button size="small"
                     type="primary"
                     @click="submit">提交</el-button>
        </el-form-item>
      </el-form>
      <div class="foot"></div>
    </div>
  </div>
</template>

<style lang="scss">
</style>

<script>
import '@/style/info.scss'
import '@/style/common.scss'
import { api, devBaseURL } from '@/api'
import { HTTPSUCCESS, HTTPDATAFAIL, HTTPPARAMFAIL, HTTPUNKOWNFAIL } from '@/components/constant'
import { getToken, getUser } from '@/utils/auth'

export default {
  data() {
    return {
      notice: null
    }
  },
  activated() {
    this.getNotice()
  },
  methods: {
    getNotice() {
      this.$http.get(api.NOTICE_DETAIL).then(
        res => {
          if (res.error.code === HTTPSUCCESS) {
            this.notice = res.result
          }
        }
      )
    },
    submit() {
      const params = {
        notice: this.notice
      }
      this.$http.get(api.NOTICE_SUBMIT, params).then(
        res => {
          if (res.error.code === HTTPSUCCESS) {
            this.$msg._message('发布公告成功', 'success')
            this.getNotice()
          }
        }
      )
    }
  }
}
</script>
